package com.xuecheng.content.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xuecheng.api.content.CourseBaseApi;
import com.xuecheng.api.content.model.qo.QueryCourseBaseModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.entity.CourseBase;
import com.xuecheng.content.service.CourseBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 课程基本信息 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController

public class CourseBaseController implements CourseBaseControllerApi, CourseBaseApi {

    @Autowired
    private CourseBaseService  courseBaseService;

    @GetMapping("courseBase")
    public List<CourseBase> queryAll(){
        List<CourseBase> list = courseBaseService.list(Wrappers.emptyWrapper());
        return list;
    }

    @PostMapping("course/list")
    @Override
    public PageVO queryCourseBaseList(PageRequestParams params,
                                      @RequestBody QueryCourseBaseModel model) {
        Long companyId = SecurityUtil.getCompanyId();
        PageVO pageVO = courseBaseService.queryCourseBaseList(params, model,companyId);
        return pageVO;
    }
}
